package com.kuhyygy.service;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;

public class SimpleService extends Service {
	
	public static final String FLAG = "SimpleService";

	@Override
	public IBinder onBind(Intent arg0) {
		Log.i(FLAG, "onBind --> ");
		return null;
	}

	@Override
	public void onCreate() {
		Log.i(FLAG, "onCreate --> ");
		super.onCreate();
	}

	@Override
	public void onDestroy() {
		Log.i(FLAG, "onDestroy --> ");
		super.onDestroy();
	}

	@Override
	public int onStartCommand(Intent intent, int flags, int startId) {
		Thread t = new Thread(new MyThread());
		t.start();
		return super.onStartCommand(intent, flags, startId);
	}
	
	class MyThread implements Runnable {

		@Override
		public void run() {
			Log.i(FLAG, "onStartCommand --> 线程ID:" + Thread.currentThread().getId());
			Log.i(FLAG, "开始下载文件 ...");
			try {
				Thread.sleep(5000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			Log.i(FLAG, "文件下载完毕");
		}
		
	}

}
